# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Eric Belanger <eric@archlinux.org>
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>

pkgname=freeglut
pkgver=3.4.0
pkgrel=1
pkgdesc="Provides functionality for small OpenGL programs"
url="https://freeglut.sourceforge.net/"
arch=(x86_64)
license=(MIT)
depends=(libxi libxrandr libgl)
makedepends=(mesa glu libxxf86vm cmake ninja git)
replaces=(glut)
provides=(glut)
conflicts=(glut)
_commit=63c0e78d84ecbfcf8accd8bac04404427899053b  # tags/v3.4.0
source=("git+https://github.com/FreeGLUTProject/freeglut#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd freeglut
  git describe --tags | sed 's/^v//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd freeglut
}

build() {
  cmake -S freeglut -B build -G Ninja \
    -DFREEGLUT_BUILD_STATIC_LIBS=OFF \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DCMAKE_BUILD_TYPE=None
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  ln -s glut.pc "$pkgdir/usr/lib/pkgconfig/freeglut.pc"

  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" freeglut/COPYING
}

# vim:set sw=2 sts=-1 et:
